package com.muxi.association.config;

import com.muxi.association.interceptor.AssociationInterceptor;
import com.muxi.association.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author ZXW
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    @Resource
    private AssociationInterceptor associationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器，配置拦截地址
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                //放行路径
                .excludePathPatterns(
                "/api/**",
                "/common/**",
                "/css/**",
                "/images/**",
                "/js/**",
                "/lib/**",
                "/favicon.ico",
                "/back/login",
                "/back/register",
                "/api/back/login"
        );
        registry.addInterceptor(associationInterceptor).addPathPatterns("/api/back/association/member/deletes", "/api/back/association/member/update");
    }
}
